package com.djsearch.ui;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ListView;

import com.djsearch.R;
import com.djsearch.adapter.JiPiaoListViewAdapter;
import com.djsearch.bean.GroupBuyGoods;
import com.djsearch.bean.PlaneTicket;
import com.djsearch.controller.JSONResp;
/**
 * 机票搜索结果页面
 * @author chenyang2
 *
 */
public class JiPiaoActivity extends BaseActivity{
	
	private Context mContext;
	private List<PlaneTicket> ticketList;
	private Button btnBack;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getWindow().requestFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.jipiao_layout);
		mContext = this;
		ticketList = new ArrayList<PlaneTicket>();//当前页面数据
		getTicketData();
		//初始化主界面
		initView();
		//初始化主界面相关点击事件
		initOnClick();
		//
		initHandler();
		
	}

	

	@Override
	void initHandler() {
		// TODO Auto-generated method stub
		
	}

	@Override
	void initView() {
		// TODO Auto-generated method stub
		btnBack = (Button)findViewById(R.id.btnBack);
		ListView jiPiaoListView = (ListView)findViewById(R.id.jipiaoListView);
		JiPiaoListViewAdapter jiPiaoListViewAdapter = new JiPiaoListViewAdapter(mContext, ticketList);
		jiPiaoListView.setAdapter(jiPiaoListViewAdapter);
	}

	@Override
	void initOnClick() {
		// TODO Auto-generated method stub
		btnBack.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivity(mContext, null, 1);
			}
		});
	}

	private void getTicketData() {
		Intent intent = getIntent();   
	    Object[] cobjs = (Object[])intent.getSerializableExtra("data");  
	    for (int i = 0; i < cobjs.length; i++) {   
	    	PlaneTicket planeTicket = (PlaneTicket)cobjs[i];   
	    	ticketList.add(planeTicket);   
	       } 
	}
	
	@Override
	void getDataToResolve(JSONResp response) {
		// TODO Auto-generated method stub
		
	}

}
